using System;
using System.Collections.Generic;
using System.Text;

using Weazel.Microblaze.Simulator.Engine;

namespace Weazel.Microblaze.Simulator.Components.Microblaze.Instructions
{
    public class Xor : Instruction
    {
        public override int CycleCount
        {
            get { return 1; }
        }

        public Xor()
            : base("xor")
        {
        }

        public override void Execute(MicroblazeComponent MicroblazeComponent)
        {
            uint sa = MicroblazeComponent.ReadRegister(SourceRegisterA);
            uint sb = MicroblazeComponent.ReadRegister(SourceRegisterB);

            // compute and save
            MicroblazeComponent.WriteRegister(DestinationRegister, sa ^ sb, Address);
        }

        public override string ToString()
        {
            return string.Format("xor r{0}, r{1}, {2}",
              DestinationRegister,
              SourceRegisterA,
              ImmediateValue
            );
        }
    }
}
